package http

import (
	"github.com/valyala/fasthttp"
	"gateway/utils"
	"strconv"
)
type CommonResponse struct {
	Code string    `json:"code"`
	Msg  string `json:"msg"`
	Data interface{} `json:"data"`
}
func ServeJson(ctx *fasthttp.RequestCtx,code int,message string){
	ctx.Response.Header.Add("Content-Type","application/json; charset=utf-8")
	res,_ := utils.JSONMarshal(&CommonResponse{
		strconv.Itoa(code),message,"",
	})
	ctx.Write(res)
}

func ServeMaxRequestJson(ctx *fasthttp.RequestCtx,data interface{}){
	ctx.Response.Header.Add("Content-Type","application/json; charset=utf-8")
	res,_ := utils.JSONMarshal(&CommonResponse{
		"0","当前服务繁忙,请稍后尝试",data,
	})
	ctx.Write(res)
}